package com.glodon.paas.databag.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Index;

import com.glodon.paas.job.model.TaskStatus;

@Entity
@Table(name = "databag_task")
public class DatabagTask implements Serializable {
    private static final long serialVersionUID = 1L;
    @javax.persistence.Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String id;
    @Index(name = "IDX_TASK_DATABAG_ID")
    private String databagId;
    private String userId;
    private String taskId;// 来自job-server的Id
    private String type;// 任务名称
    @Index(name = "IDX_TASK_STARTTIME")
    private Date startTime = new Date();// 调度请求转发到job-server时间
    private Date responseTime;// 接收到job-server返回状态的时间
    private String input; // 输入model
    private String output; // 来至job-server的返回model
    private Integer progress = 0;// 任务执行进度
    private String message;
    @Enumerated(EnumType.STRING)
    private TaskStatus status;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDatabagId() {
        return databagId;
    }

    public void setDatabagId(String jobId) {
        this.databagId = jobId;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getResponseTime() {
        return responseTime;
    }

    public void setResponseTime(Date responseTime) {
        this.responseTime = responseTime;
    }

    public String getInput() {
        return input;
    }

    public void setInput(String input) {
        this.input = input;
    }

    public String getOutput() {
        return output;
    }

    public void setOutput(String output) {
        this.output = output;
    }

    public Integer getProgress() {
        return progress;
    }

    public void setProgress(Integer progress) {
        this.progress = progress;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public TaskStatus getStatus() {
        return status;
    }

    public void setStatus(TaskStatus status) {
        this.status = status;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String ownerId) {
        this.userId = ownerId;
    }

    @Override
    public String toString() {
        return "DatabagTask [id=" + id + ", databagId=" + databagId + ", taskId=" + taskId + ", type=" + type
                + ", startTime=" + startTime + ", responseTime=" + responseTime + ", input=" + input + ", output="
                + output + ", progress=" + progress + ", message=" + message + ", status=" + status + "]";
    }
}
